<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-/mhDoLbDldZc3qpsJHpLogda//BVZbgYuw6kof4u2FrCedxOtgRZDTHgHUhOCVim"
        crossorigin="anonymous"></script>
</head>

<body>
    <select class="form-select" aria-label="Default select example">
        <option selected>广东</option>
        <option value="1">河北</option>
        <option value="2">北京</option>
        <option value="3">浙江</option>
    </select>
    <p></p>
    <script>
        //创建XMLHttpRequest对象
        const xhr = new XMLHttpRequest()
        //配置请求方法和请求url地址
        xhr.open('GET', 'https://hmajax.itheima.net/api/province')
        //监听loadend事件 接收响应结果
        xhr.addEventListener('loadend', () => {
            console.log(xhr.response);
            const data = JSON.parse(xhr.response)
            console.log(data.list.join('<br>'))
            document.querySelector('p').innerHTML = data.list.join('<br>')
        })
        // 发送请求
        xhr.send()
    </script>
</body>

</html>